
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="common/head::head"></head>
<body>

<div th:include="common/header::header"></div>

<div class="layui-container fly-marginTop">
    <div style="padding: 20px; background-color: #F2F2F2;">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">激活邮箱</div>
                    <div class="layui-card-body">
                        <ul class="layui-form">
                            <li class="layui-form-li">
                                <label for="activate">您的邮箱：</label>
                                <span class="layui-form-text" id="activate"><span th:text="${activateU?.email}"></span>
                                   <em style="color:#999;" th:if="${activateU?.emailActivate == 'Y'}">（已成功激活）</em>
                                   <em style="color:#c00;" th:if="${activateU?.emailActivate != 'Y'}">（尚未激活）</em>
                                    <a style="color:#c00;" th:if="${activateU?.emailActivate != 'Y'}" th:href="${userMailHost}">（登录邮箱激活）</a>
                                </span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">说明</div>
                    <div class="layui-card-body">
                        <ul class="layui-form">
                            <li class="layui-form-li" style="margin-top: 20px; line-height: 26px;">
                                <div>
                                    1. 如果您未收到邮件，或激活链接失效，您可以
                                    <a class="layui-form-a" style="color:#4f99cf;" id="LAY-activate" href="javascript:;" th:email="${activateU?.email}">重新发送邮件</a>，或者
                                    <a class="layui-form-a" style="color:#4f99cf;" id="LAY-changemail" href="javascript:;">更换邮箱</a>；
                                </div>
                                <div>
                                    2. 如果您始终没有收到邮件，请注意查看您邮箱中的垃圾邮件；
                                </div>
                                <div>
                                    3. 如果你实在无法激活邮件，您还可以联系：<span th:text="${adminEmail}"></span>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<div th:include="common/footer::footer"></div>

<script th:src="@{/layui/layui.js}"></script>
<script th:inline="javascript">
  layui.cache.page = 'user';
  layui.cache.user = {
      username: [[${user==null?'游客':user.username}]]
      ,id: [[${user==null?-1:user.id}]]
  };
  layui.config({
    version: "3.0.0"
    ,base: '/mods/'
  }).extend({
    fly: 'index'
  }).use(['fly','layer'], function () {
      var fly = layui.fly,
          layer = layui.layer;

      $('#LAY-changemail').on('click', function(){
          layer.prompt(function(val, index){
              layer.close(index);
              var reg = /^\w+((.\w+)|(-\w+))@[A-Za-z0-9]+((.|-)[A-Za-z0-9]+).[A-Za-z0-9]+$/; //正则表达式
              if (!reg.test(val)) {
                  layer.msg("请输入正确的邮箱");
              }else {
                  fly.json("/api/changeEmail",
                      {
                          o: $('#LAY-activate').attr('email'),
                          n: val
                      },
                      function (res) {
                      if(res.status === 0){
                          layer.alert('已成功更换邮箱，请注意查收激活邮件，并使用新邮箱登录。', {
                              icon: 1
                          });
                      }else {
                          layer.msg(res.msg);
                      };
                  });
              }
          });
      });
  });
</script>

</body>
</html>